package com.lyh.system.service.impl;

import com.lyh.common.enums.AmountStatusEnum;
import com.lyh.common.enums.RelationTypeEnum;
import com.lyh.common.utils.DateUtils;
import com.lyh.common.utils.uuid.IdUtils;
import com.lyh.system.domain.SysRechargeAmount;
import com.lyh.system.domain.SysRelationValue;
import com.lyh.system.mapper.SysRechargeAmountMapper;
import com.lyh.system.mapper.SysRelationValueMapper;
import com.lyh.system.service.ISysRechargeAmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-26
 */
@Service
public class SysRechargeAmountServiceImpl implements ISysRechargeAmountService
{
    @Autowired
    private SysRechargeAmountMapper sysRechargeAmountMapper;

    @Autowired
    private SysRelationValueMapper sysRelationValueMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysRechargeAmount selectSysRechargeAmountById(Long id)
    {
        SysRechargeAmount sysRechargeAmount = sysRechargeAmountMapper.selectSysRechargeAmountById(id);
        //查找权益
        SysRelationValue value = new SysRelationValue();
        value.setBusinessId(id.toString());
        value.setCode(RelationTypeEnum.RechargeAmount.getCode());
        List<SysRelationValue> sysRelationValues = sysRelationValueMapper.selectSysRelationValueList(value);
        sysRechargeAmount.setList(sysRelationValues);
        return sysRechargeAmount;
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param sysRechargeAmount 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysRechargeAmount> selectSysRechargeAmountList(SysRechargeAmount sysRechargeAmount)
    {
        List<SysRechargeAmount> list = sysRechargeAmountMapper.selectSysRechargeAmountList(sysRechargeAmount);
        if(list!=null && list.size()>0){
            list.stream().forEach(c->{
                c.setStatusName(c.getStatus() ==1 ? AmountStatusEnum.OK.getInfo():AmountStatusEnum.DISABLE.getInfo());
            });
        }
        return list;
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param sysRechargeAmount 【请填写功能名称】
     * @return 结果
     */
    @Override
    @Transactional
    public int insertSysRechargeAmount(SysRechargeAmount sysRechargeAmount)
    {

        return 0;
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param sysRechargeAmount 【请填写功能名称】
     * @return 结果
     */
    @Override
    @Transactional
    public int updateSysRechargeAmount(SysRechargeAmount sysRechargeAmount)
    {

        return sysRechargeAmountMapper.updateSysRechargeAmount(sysRechargeAmount);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteSysRechargeAmountByIds(Long[] ids)
    {


        return sysRechargeAmountMapper.deleteSysRechargeAmountByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysRechargeAmountById(Long id)
    {
        return sysRechargeAmountMapper.deleteSysRechargeAmountById(id);
    }
}
